var pdoc = window.dialogArguments.document;
function $2(nodeName) {
	return pdoc.getElementsByName(nodeName);
};

function getParentTR(dom) {
	if (dom) {
		if (dom.tagName.toLowerCase() == 'tr') {
			return dom;
		} else {
			return getParentTR(dom.parentNode);
		}
	} else {
		return null;
	}
}

window.onload = function() {

	var repeatLength = $2("my:公司").length;

	var length = result.length;

	var upTR = getParentTR($2("my:公司")[repeatLength - 1]);
	for (var i = 0; i < length; i++) {
		upTR.id = "oper";
		window.dialogArguments.addEmpty();
	}

	for (var i = 0; i < repeatLength; i++) {
		getParentTR($2("my:公司")[0]).id = "oper";
		window.dialogArguments.del();
	}

	for (var i = 0; i < length; i++) {
		$2("my:公司")[i].value = result[i]['company'] ? result[i]['company'] : "";
		$2("my:段别")[i].value = "子科目段";
		$2("my:科目代码")[i].value = result[i]['subject']
				? result[i]['subject']
				: "";
		$2("my:项目令号")[i].value = result[i]['number'] ? result[i]['number'] : "";
		$2("my:科目说明")[i].value = result[i]['description']
				? result[i]['description']
				: "";
	}
	window.close();
}